Building nTier Applications with Entity Framework ServicesPart 2
Check Out Your Local User Groups!San Diego Cloud Computing User Groupwww.azureusergroup.com/group/sandiegoazureusergroupSan Diego .NET Developers Groupwww.sddotnetdg.orgSan Diego .NET User Groupwww.sandiegodotnet.comSan Diego SQL Server User Groupwww.sdsqlug.org
Win Free Software!RulesProvide your business card (or email and name)*Indicate on the back what software you are interested inOtherwise I will pick Winners will be picked next week*Yes, most likely I’m going to send you and email about my user group (sddotnetdg.org) and or web site (dotNetTips.com)PrizesCodeRush and Refactor Pro from DevExpress (4)SecondCopy (automatic backup software) (5) *CodeIt.Right Standard from SubMain (4)*Requires mailing address and phone number
Agenda
Exposing your Data over the wire (internet)Service Layer
User ExperienceSecurityActive Directory, Card Space,  Windows Identity FoundationUI ComponentsWindows Forms, Windows Presentation Foundation, ASP.NET (AJAX, MVC), Silverlight, Windows MobilePresentation LayerLocal Storage/ CacheCommunications LayerWindows Communication Foundation (WCF), WCF Data Services, Web Services, Sync Services, Azure (Cloud), RIA Services, Workflow ServicesBusiness LayerBusiness EntitiesT4 TemplatesBusiness ComponentsBusiness WorkflowWindows Workflow FoundationData LayerEntity Framework, LINQ to SQL, DataSetsSQL Server
SOAP IssuesComplexSlowHeavyweightTied to development tools and librariesNot supported universallyCross-vendor/platform interoperability NOT perfect
REST == Architectural Stylefor connecting distributed applicationsServer-side resources identified by URIAccess resources over HTTP/ HTTPSReturned data is “plain”: Atom, plain-XML or JSON
What is REST?Representational State TransferAn architectural style developed by Roy FieldingResource based not RPC basedBased on HTTPStandard resource formatsStateless communication between client and serverGET, POST, PUT, DELETEAddressable resources + hyperlinking
XMLXMLJSONJSONHow REST WorksClientServerURLResourcesVERB (GET, POST, PUT, DELETE)Resource 1RepresentationResource 2StatusRepresentation
What is OData?Protocol for sharing data via HTTP, AtomPub and JSONOpenA way to break down data silos The ATOMPub and JSON format used by “Astoria” or WCF Data Services
Data Services ClientsHTTP(Open Data Protocol)WCF Data ServicesSQL Server 2008 Reporting ServicesWindows Azure Table Storage
OData SDK – Client Library(March 2010)OData JavaScript LibraryOData SDK for PHPRestlet ext. for JavaOData client lib for WP7OData SDK for ObjCData Services update for .NET 3.5 SP1.NET 4.0Silverlight 4.0
OData ConsumersModern web browsersOData explorerExcel 2010 – PowerPivotLINQPadSesame
Easily Expose Your EntitiesWCF Data Services & OData
WCF Data Services OverviewFramework from Microsoft that that facilitates the creation of RESTful data services via HTTP endpointsShipped with .NET 3.5 SP1Updates for 3.1 SP1 and .NET 4.0Built on top of WCF4Data representation in ATOM or JSON
WCF Data Services OverviewAutomates the exposure of data as RESTful resourcesAnything that implements IQueryable<T> and IUpdatable<T>Entity Framework3rd party ORMsLINQ to SQL, custom data driven CLR classesCustom URI based querying
HTTPOpen Data Protocol (OData)Hosting/HTTP ListenerData Services RuntimeData Access LayerEntityFrameworkCustom LINQ ProviderRelational DatabaseOther Sources
WCF 4Programming ModelCore ServicesWeb HTTP ServicesData ServicesRIA ServicesWorkflow ServicesService ModelData ContractService ContractService  BehaviorChannel ModelFormats(Atom, JSON, XML,…)Transports(HTTP, TCP, …)Protocols(SOAP, HTTP, Open Data Protocol,…)
URL ConventionsAddressing entities and setsPresentation options
Service OperationsAdditional way to expose resources via URIs[WebGet] is used for an addressable query[WebInvoke] is used for insert, update, and deleteCan return a scalar valueIEnumerable or IQueryable Astoria’s URI exposes the Service OperationIf you use IQueryable you can append query strings to the URI
Data InterceptorsQuery InterceptorsLogic that will run when a resource is requestedCan be used to limit the data viewed, log, or perform security checkChange InterceptorsLogic that will run when a change (Add/Edit/Delete) request is made
Securing WCF Data ServicesUsing the Host’s authentication modelRole  based authorizationEntitySetRightsHiding Sensitive Data[IgnoreProperties]QueryInterceptorsServiceOperations to validate usersBrute force: HTTPS, SSL, IP FilteringSQL Server Security should not be ignored either!
What’s New in .NET 4Data BindingNew DataServiceCollection class provides simplified binding of data service data to (WPF) controls. Includes auto updating.Counting Entities in an Set $count - total number of resources returned by a URI$inlinecount - total resource count together with the resource dataServer-driven Paging Service can be configured to return requested resources as a set of paged responses
JSON/XMLHTTP/RESTWCF  Data ServiceDataServiceContextData BindingHTTP/RESTEntity FrameworkObjectContext availableObjectContext not availableDistributed system – WCF Data serviceSQL Server 2008
What’s New in .NET 4Query ProjectionsQuery results can be modified to include only a subset of properties by using the new $select query option.Custom Data Service ProvidersCan implement a set of new data service provider interfaces, you can use various types of data with a data service, even when the data model changes during execution.Streaming of Binary ResourcesThis enables you to retrieve and save binary large object data independent of the entity to which it belongs.
Summary

Building nTier Applications with Entity Framework Services (Part 2)

  • 1.
    Building nTier Applicationswith Entity Framework ServicesPart 2
  • 3.
    Check Out YourLocal User Groups!San Diego Cloud Computing User Groupwww.azureusergroup.com/group/sandiegoazureusergroupSan Diego .NET Developers Groupwww.sddotnetdg.orgSan Diego .NET User Groupwww.sandiegodotnet.comSan Diego SQL Server User Groupwww.sdsqlug.org
  • 4.
    Win Free Software!RulesProvideyour business card (or email and name)*Indicate on the back what software you are interested inOtherwise I will pick Winners will be picked next week*Yes, most likely I’m going to send you and email about my user group (sddotnetdg.org) and or web site (dotNetTips.com)PrizesCodeRush and Refactor Pro from DevExpress (4)SecondCopy (automatic backup software) (5) *CodeIt.Right Standard from SubMain (4)*Requires mailing address and phone number
  • 5.
  • 6.
    Exposing your Dataover the wire (internet)Service Layer
  • 7.
    User ExperienceSecurityActive Directory,Card Space, Windows Identity FoundationUI ComponentsWindows Forms, Windows Presentation Foundation, ASP.NET (AJAX, MVC), Silverlight, Windows MobilePresentation LayerLocal Storage/ CacheCommunications LayerWindows Communication Foundation (WCF), WCF Data Services, Web Services, Sync Services, Azure (Cloud), RIA Services, Workflow ServicesBusiness LayerBusiness EntitiesT4 TemplatesBusiness ComponentsBusiness WorkflowWindows Workflow FoundationData LayerEntity Framework, LINQ to SQL, DataSetsSQL Server
  • 8.
    SOAP IssuesComplexSlowHeavyweightTied todevelopment tools and librariesNot supported universallyCross-vendor/platform interoperability NOT perfect
  • 9.
    REST == ArchitecturalStylefor connecting distributed applicationsServer-side resources identified by URIAccess resources over HTTP/ HTTPSReturned data is “plain”: Atom, plain-XML or JSON
  • 10.
    What is REST?RepresentationalState TransferAn architectural style developed by Roy FieldingResource based not RPC basedBased on HTTPStandard resource formatsStateless communication between client and serverGET, POST, PUT, DELETEAddressable resources + hyperlinking
  • 11.
    XMLXMLJSONJSONHow REST WorksClientServerURLResourcesVERB(GET, POST, PUT, DELETE)Resource 1RepresentationResource 2StatusRepresentation
  • 12.
    What is OData?Protocolfor sharing data via HTTP, AtomPub and JSONOpenA way to break down data silos The ATOMPub and JSON format used by “Astoria” or WCF Data Services
  • 13.
    Data Services ClientsHTTP(OpenData Protocol)WCF Data ServicesSQL Server 2008 Reporting ServicesWindows Azure Table Storage
  • 14.
    OData SDK –Client Library(March 2010)OData JavaScript LibraryOData SDK for PHPRestlet ext. for JavaOData client lib for WP7OData SDK for ObjCData Services update for .NET 3.5 SP1.NET 4.0Silverlight 4.0
  • 15.
    OData ConsumersModern webbrowsersOData explorerExcel 2010 – PowerPivotLINQPadSesame
  • 16.
    Easily Expose YourEntitiesWCF Data Services & OData
  • 17.
    WCF Data ServicesOverviewFramework from Microsoft that that facilitates the creation of RESTful data services via HTTP endpointsShipped with .NET 3.5 SP1Updates for 3.1 SP1 and .NET 4.0Built on top of WCF4Data representation in ATOM or JSON
  • 18.
    WCF Data ServicesOverviewAutomates the exposure of data as RESTful resourcesAnything that implements IQueryable<T> and IUpdatable<T>Entity Framework3rd party ORMsLINQ to SQL, custom data driven CLR classesCustom URI based querying
  • 19.
    HTTPOpen Data Protocol(OData)Hosting/HTTP ListenerData Services RuntimeData Access LayerEntityFrameworkCustom LINQ ProviderRelational DatabaseOther Sources
  • 20.
    WCF 4Programming ModelCoreServicesWeb HTTP ServicesData ServicesRIA ServicesWorkflow ServicesService ModelData ContractService ContractService BehaviorChannel ModelFormats(Atom, JSON, XML,…)Transports(HTTP, TCP, …)Protocols(SOAP, HTTP, Open Data Protocol,…)
  • 21.
    URL ConventionsAddressing entitiesand setsPresentation options
  • 22.
    Service OperationsAdditional wayto expose resources via URIs[WebGet] is used for an addressable query[WebInvoke] is used for insert, update, and deleteCan return a scalar valueIEnumerable or IQueryable Astoria’s URI exposes the Service OperationIf you use IQueryable you can append query strings to the URI
  • 24.
    Data InterceptorsQuery InterceptorsLogicthat will run when a resource is requestedCan be used to limit the data viewed, log, or perform security checkChange InterceptorsLogic that will run when a change (Add/Edit/Delete) request is made
  • 26.
    Securing WCF DataServicesUsing the Host’s authentication modelRole based authorizationEntitySetRightsHiding Sensitive Data[IgnoreProperties]QueryInterceptorsServiceOperations to validate usersBrute force: HTTPS, SSL, IP FilteringSQL Server Security should not be ignored either!
  • 27.
    What’s New in.NET 4Data BindingNew DataServiceCollection class provides simplified binding of data service data to (WPF) controls. Includes auto updating.Counting Entities in an Set $count - total number of resources returned by a URI$inlinecount - total resource count together with the resource dataServer-driven Paging Service can be configured to return requested resources as a set of paged responses
  • 28.
    JSON/XMLHTTP/RESTWCF DataServiceDataServiceContextData BindingHTTP/RESTEntity FrameworkObjectContext availableObjectContext not availableDistributed system – WCF Data serviceSQL Server 2008
  • 29.
    What’s New in.NET 4Query ProjectionsQuery results can be modified to include only a subset of properties by using the new $select query option.Custom Data Service ProvidersCan implement a set of new data service provider interfaces, you can use various types of data with a data service, even when the data model changes during execution.Streaming of Binary ResourcesThis enables you to retrieve and save binary large object data independent of the entity to which it belongs.
  • 31.
  • 32.
    ResourcesWCF Data ServicesLearning Guide:http://msdn.microsoft.com/en-us/data/bb931106.aspxWCF Data Services Team Bloghttp://blogs.msdn.com/astoriateam
  • 33.

Editor's Notes

  • #7 Goals:To show a new way of serving up dateGet you thinking to learn more when you leave this presentation
  • #16 BrowsersMost modern browsers allow you to browse Atom based feeds. Simply point your browser at one of the OData producers.OData ExplorerA Silverlight application that can browse OData Services. It is available as part of the OData SDK Code Samples, and is available online at Silverlight.net/ODataExplorer.Excel 2010PowerPivot for Excel 2010 is a plugin to Excel 2010 that has OData support built-in.LINQPadLINQPad is a tool for building OData queries interactively.SesameA preview version of Fabrice Marguerie&apos;s OData Browser.Client LibrariesClient libraries are programming libraries that make it easy to consume OData services. We already have libraries that target:JavascriptPHPJavaWindows Phone 7 SeriesiPhone (Objective C).NET
  • #23 Demo: AdvertureWorksServiceDemo: AdventureWorks.Client
  • #25 Demo: AdvertureWorksServiceDemo: AdventureWorks.Client
  • #27 Demo: AdvertureWorksServiceDemo: AdventureWorks.Client
  • #32 Demo: AdvertureWorksServiceDemo: AdventureWorks.Client